<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>登录</title>
		<link href="Css/rest.css" type="text/css" rel="stylesheet" />
		<link href="Css/layout.css" type="text/css" rel="stylesheet" id="cssfile" />
	</head>

	<body>
		<div class="fang_blue_bg w100 bt_dba80d height800">
			<div class="w1000">
				<div class="chongzhi_box">
					<h1 class="h1_bg h1_style">用户登录</h1>
					<form name="reg_form" id="reg_form" method="">
						<div id="login_form">
							<input type="hidden">
							<div class="sec_com ml87mt23">
								<label class="label_com label_com2">账号</label>
								<input name="useraccount" type="text" id="login_user" size="10" class="text_com text_com2">
							</div>
							<div class="sec_com ml87mt15">
								<label class="label_com label_com2">登陆密码</label>
								<input name="userpwd" type="password" id="login_pwd" size="13" class="text_com text_com2" />
							</div>
							<div class="sec_com ml87mt15 sec_com2">
								<input type="button" name="Submit" value="登录" onclick="login()" id="reg_button" class="btn_com btn_big zhuce_btn" />
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
		<div class="footer">
			<div class="foot w1000 te_align">2016 © CC Online Entertainment</div>
		</div>
		<script type="text/javascript" src="Js/jquery-1.8.0.min.js"></script>
		<script>
			function login() {
				var login_user = document.getElementById("login_user").value;
				var login_pwd = document.getElementById("login_pwd").value;
				var reg_name = /^(u-)[a-zA-Z\d]{6,16}$/;
				var reg_pwd = /^[a-zA-Z\d]{8,16}$/;
				if(!reg_name.test(login_user)){
					alert('用户名为6-16位数字或字母');
					return false;
				}
				if(!reg_pwd.test(login_pwd)){
					alert('密码为8-16位数字或字母');
					return false;
				}
				var form_data = $("#reg_form").serialize();
				$.ajax({
					dataType: "json",
					type: "post",
					url: "./service/service.php?act=login",
					data: form_data,
				}).then(function(data) {
					console.log(data);
					if(data.code == 1) {
						console.log(data);
						alert('登录成功');
						self.location.href = "result.php";
					} else {
						alert(data.msg);
					}
				})
			}
		</script>
	</body>

</html>